package com.teamit.service;

import java.util.List;

import com.teamit.dao.EmployeeDao;
import com.teamit.entity.Employee;
import com.teamit.util.StringUtil;

public class EmployeeService {
	
	EmployeeDao ed = new EmployeeDao();
	public Employee findByName(String name){
		return ed.findByName(name);
	}
	public List<Employee> findByProject(String projectId){
		return ed.findByProject(projectId);
	}
	public List<Employee> findAll(){
		return ed.findAll();
	} 
	public Employee findById(String id){
		return ed.findById(id);
	}
	
	public Employee login(String name,String password){
		System.out.println(name);
		Employee employee = ed.findByName(name);
		if(employee != null && employee.getPassword().equals(StringUtil.sha1(password))){
			return employee;
		}else{
			return null;
		}
		
	}
	public String findIdByName(String name){
		Employee employee=ed.findByName(name);
		if(employee==null){
			return null;
		}
		return employee.getId();
	}

}
